<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>try-catch捕获异常</title>
</head>
<body>
    <p>我的老婆天下第一美</p>
    <script>
        try{
            const p = document.querySelector('.p')
            p.style.color = 'red'
        }
        catch(error){
            console.log(error.message);
            throw new Error('没有获取到DOM元素')
        }
        finally{
            alert('111')
        }
    </script>
</body>
</html>